import java.util.ArrayList;
import java.util.List;


public class StockVehiculosDisponibles implements StockVehiculos {
	private List<Vehiculo> vehiculos;
	
	
	public StockVehiculosDisponibles() {
		
		this.vehiculos = new ArrayList<Vehiculo>();
	}
	public StockVehiculosDisponibles(List<Vehiculo> vehiculos) {
		
		this.vehiculos = vehiculos;
	}

	public List<Vehiculo> getVehiculos() {
		return vehiculos;
	}

	public void setVehiculos(List<Vehiculo> vehiculos) {
		this.vehiculos = vehiculos;
	}

	public boolean anyadirVehiculo(Vehiculo v) {
		if(vehiculos.contains(v)){
			System.out.println("El vehiculo ya existe en el Stock");
			return false;
		}else{
			vehiculos.add(v);
			return true;
		}
		
	}

	public boolean eliminarVehiculo(Vehiculo v) {
		if(vehiculos.contains(v)){
			vehiculos.remove(v);
			return true;
			
		}else{
			System.out.println("El vehiculo "+v+" no existe en el Stock");
			return false;
			
		}
		
	}

	public boolean modificarVehiculo(Vehiculo v1, Vehiculo v2) {
		if(vehiculos.contains(v1)){
			vehiculos.remove(v1);
			vehiculos.add(v2);
			return true;
			
		}else{
			
			System.out.println("El vehiculo no se puede modificar pues no existe en el Stock");
			return false;
		}
		
	}
	public int size(){
		return vehiculos.size();
	}
	public Vehiculo get(Integer i){
		return vehiculos.get(i);
	}
	public String toString(){
		String s="";
		for(int i=0;i<vehiculos.size();i++){
			s+=vehiculos.get(i)+"\n";
			
		}
		return s;
		
	}


}